﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WaterRevenueMS.Domain.Common.Models;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;

namespace WaterRevenueMS.Domain.ViewModels.BasicSet.HandSetType
{
    public class HandSetTypeModel : EntityCommon
    {
        public HandSetTypeModel()
        {

            DefaultValue = 0;
            Search = new SearchModel();
            HandSetItems = new List<SelectListItem>
            {
                new SelectListItem{Text="请选择手抄器型号",Value="0"},
                new SelectListItem{Text="无源分线表手抄器",Value="1"},
                new SelectListItem{Text="无源总线表手抄器",Value="2"},
                new SelectListItem{Text="16路脉冲采集器手抄器",Value="3"},
                new SelectListItem{Text="32路脉冲采集器手抄器",Value="4"},
                new SelectListItem{Text="合肥手抄器",Value="5"},
                new SelectListItem{Text="脉冲国标手抄器",Value="6"},
                new SelectListItem{Text="潍微无源手抄器",Value="7"},
                new SelectListItem{Text="HD6305_阶梯水价",Value="8"},
                new SelectListItem{Text="HD6305_多用途手抄器",Value="9"},
                new SelectListItem{Text="HT2900手抄器(采集器版)",Value="10"},
                new SelectListItem{Text="HD6305_丰城手抄器",Value="11"}
            };
            BoTLItems = new List<SelectListItem>
            {
             new SelectListItem{Text="300",Value="300"},
             new SelectListItem{Text="600",Value="600"},
             new SelectListItem{Text="1200",Value="1200"},
             new SelectListItem{Text="2400",Value="2400"},
             new SelectListItem{Text="4800",Value="4800"},
             new SelectListItem{Text="9600",Value="9600"},
             new SelectListItem{Text="19200",Value="19200"},
             new SelectListItem{Text="38400",Value="38400"},
             new SelectListItem{Text="57600",Value="57600"},
             new SelectListItem{Text="115200",Value="115200"}
            };
            Tong_XDKItems = new List<SelectListItem>
            {
                new SelectListItem{Text="USB",Value="0"},
                new SelectListItem{Text="COM1",Value="1"},
                new SelectListItem{Text="COM2",Value="2"},
                new SelectListItem{Text="COM3",Value="3"},
                new SelectListItem{Text="COM4",Value="4"},
                new SelectListItem{Text="COM5",Value="5"},
                new SelectListItem{Text="COM6",Value="6"},
                new SelectListItem{Text="COM7",Value="7"},
                new SelectListItem{Text="COM8",Value="8"},
                new SelectListItem{Text="COM9",Value="9"},
                new SelectListItem{Text="COM10",Value="10"},
                new SelectListItem{Text="COM11",Value="11"},
                new SelectListItem{Text="COM12",Value="12"},
                new SelectListItem{Text="COM13",Value="13"},
                new SelectListItem{Text="COM14",Value="14"},
                new SelectListItem{Text="COM15",Value="15"},
                new SelectListItem{Text="COM16",Value="16"}
            
            };

            Jiao_YFSItems = new List<SelectListItem>
            {
                new SelectListItem{Text="None 无校验",Value="0"},
                new SelectListItem{Text="Even 偶校验",Value="1"},
                new SelectListItem{Text="Odd 奇校验",Value="2"}
            };

        }

         public int Id { get; set; }


        [Display(Name = "手抄器类型")]
        [Required(ErrorMessage = "手抄器类型不能为空")]
        [StringLength(16, MinimumLength = 2, ErrorMessage = "手抄器类型{2}～{1}个字符")]
         public string Shou_CQLX { get; set; }

        public string Shou_CQXHXS
        {
            get
            {
                string str = "";
                foreach (SelectListItem item in HandSetItems)
                {
                    if (item.Value == Shou_CQXH.ToString())
                    {
                        str = item.Text;
                    }
                }
                return str;
               

            }
            set { }
        }

        public byte DefaultValue { get; set; }


        [Display(Name = "手抄器型号")]
        [Required(ErrorMessage = "手抄器型号不能为空")]
       // [StringLength(2, MinimumLength = 1, ErrorMessage = "手抄器型号{2}～{1}个字符")]
        public byte Shou_CQXH { get; set; }
        public string Tong_XDK { get; set; }

        public string Tong_XDKXS 
        {
             get
            {

             if (Tong_XDK == "0")
                {
                    return "USB";
                }
                else
                {
                    return "COM" + Tong_XDK;
                    
                }
           
            }
            set { }
        }

        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        public int Bo_TL { get; set; }
        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        public byte Jiao_YFS { get; set; }
        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        public byte Shu_JW { get; set; }
        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        public byte Ting_ZW { get; set; }
        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        public byte Wo_SXY { get; set; }
        public List<SelectListItem>BoTLItems { get; set; }
        public List<SelectListItem> Tong_XDKItems { get; set; }
        public List<SelectListItem> Jiao_YFSItems { get; set; }
        public List<SelectListItem> HandSetItems { get; set; }

        public string Jiao_YFSXS
        {
            get
            {
                string str = "";
                foreach (SelectListItem item in Jiao_YFSItems)
                {
                    if (item.Value == Jiao_YFS.ToString())
                    {
                        str=item.Text;
                    }
                }
                return str;
                
            }
            set { }
        
        }
        [Display(Name = "排序序号")]
        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        public int OrderNo { get; set; }

        public SearchModel Search { get; set; }
    }
    public class SearchModel
    {
        public SearchModel()
        {

           
        }


        [Display(Name = "手抄器类型")]
        [Required(ErrorMessage = "手抄器类型不能为空")]
        [StringLength(16, MinimumLength = 2, ErrorMessage = "手抄器类型{2}～{1}个字符")]
        public string Shou_CQLX { get; set; }

        public byte DefaultValue { get; set; }

        [Display(Name = "手抄器类型")]
        public int Shou_CQXH { get; set; }

        public string Tong_XDK { get; set; }
        public int Bo_TL { get; set; }
        public byte Jiao_YFS { get; set; }
        public byte Shu_JW { get; set; }
        public byte Ting_ZW { get; set; }
        public byte Wo_SXY { get; set; }

        [Display(Name = "排序序号")]
        public int OrderNo { get; set; }
    }
}

